/*
 *   Copyright 2008 Luca Bellonda <lbellonda@gmail.com>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as
 *   published by the Free Software Foundation; either version 2 or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
#ifndef H_DBUS_ENGINE
#define H_DBUS_ENGINE

#include <Plasma/DataEngine>
#include <QtDBus/QtDBus>

#include "scanthread.h"

class DBusEngine : public Plasma::DataEngine
{
    Q_OBJECT

public:
    DBusEngine(QObject *parent, const QVariantList &args);
    ~DBusEngine();
    virtual QStringList sources() const;

    virtual void init();

protected:
    bool sourceRequestEvent(const QString & name);
    bool updateSourceEvent(const QString & name);
    //QString introspect(const QString &service, QDBusConnection &connection);
    //void setDBusData(const QString& name,  const QString& key, const QStringList &services, QDBusConnection &connection);
    void scan();

private slots:

    void serviceChangedSession(const QString &);
    void serviceChangedSystem(const QString &);
    void scanEnd();

private:
    ScanThread m_thread;
    QStringList m_sources;
    QStringList m_lastDataSession;
    QStringList m_lastDataSystem;

    //QDBusConnection m_connectionSystem;
    //QDBusConnection m_connectionSession;
};

#endif /*H_DBUS_ENGINE*/
